import {Component, EventEmitter, ComponentFactoryResolver} from "@angular/core";
import {Modal, ModalService} from "rebirth-ng";
/**
 * Created by zoushuiyun on 2017/3/3.
 */
@Component({
  selector: 're-inner-est-modal-content',
  templateUrl: 'test-inner-modal-content.component.html',
})

export  class TestInnerModalContentComponent implements Modal {

  context: { text: string };
  dismiss: EventEmitter<string>;

  constructor(private modalService: ModalService, private componentFactoryResolver: ComponentFactoryResolver) {
  }

  show() {
    this.modalService.open<string>({
      component: TestInnerModalContentComponent,
      componentFactoryResolver: this.componentFactoryResolver,
      resolve: {
        text: 'inner modal2233'
      },
      size: 'sm'
    })
      .subscribe(data => {
        console.log('Rebirth Modal -> Get ok with result:', data);
      }, error => {
        console.error('Rebirth Modal -> Get cancel with result:', error);
      });
  }

  ok() {
    this.dismiss.emit(this.context.text);
  }

  cancel() {
    this.dismiss.error(this.context.text);
  }
}
